<?php
/*** 
 * @category		
 * @package		Lib			
 * @subpackage	Model	
 * @author		wanght <whtaok@gmail.com>
 * @since		2013-3-9
 * @version		$Id: CommonViewModel.class.php 58 2013-11-27 16:20:23Z whtaok@gmail.com $
 */

class CommonViewModel extends ViewModel{
	//视图模型
	public $viewFields = array();
	public $modWhere= array();

	/**
	 * 描述：指定查询条件
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @param 		string $arg
	 * @since		2013-4-21
	 */
	public function setModWhere($arg = array(),$role='member'){
		foreach ($arg as $key=>$value ){
			if($value !== null && $value !== false && trim($value)!==''){
				$this->modWhere[$key] = $value;
			}
		}
		$this->where($this->modWhere);
		return $this;
	}
	
	/**
	 * 描述：分页设置
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-5-1
	 */
	public function listPage($totalRows=0) {
		$nowPage = isset($_REQUEST['p'])?$_REQUEST['p']:1;
		import('ORG.Util.Page');
		$listRows = 20;
		$pageObj = new Page($totalRows,$listRows);
		$list = $this->page($nowPage,$listRows)->select();
		$page = $pageObj->show();
		$rtn_data = array($list,$page);
		return $rtn_data;
	}
}

?>